package com.sciology.xpathutility.view;

import org.eclipse.jface.text.TextAttribute;
import org.eclipse.jface.text.rules.EndOfLineRule;
import org.eclipse.jface.text.rules.IRule;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.RuleBasedScanner;
import org.eclipse.jface.text.rules.SingleLineRule;
import org.eclipse.jface.text.rules.Token;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;

public class XmlRuleScanner extends RuleBasedScanner {

	private static Color TAG_COLOR = new Color (Display.getCurrent(), new RGB(127, 0, 85));
	private static Color COMMENT_COLOR = new Color (Display.getCurrent(), new RGB(64, 128,128));

	public XmlRuleScanner() {
		IToken tagToken = new Token (new TextAttribute(TAG_COLOR));
		IToken commentToken = new Token (new TextAttribute(COMMENT_COLOR));
		IRule[] rules = new IRule[3];
		rules[0] = new SingleLineRule ("<",">",tagToken);
		rules[1] = new SingleLineRule ("<","/>",tagToken);
		rules[2] = (new EndOfLineRule ("//",commentToken));
		setRules(rules);
	}

	public void setDefaultReturnToken(Token token) {

	}

}


